package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BObsvPtCfgService;
import top.tangyh.lamp.care.entity.BObsvPtCfg;
import top.tangyh.lamp.care.vo.query.ObsvPtCfgForRdParam;
import top.tangyh.lamp.care.vo.query.ObsvPtCfgQueryParam;
import top.tangyh.lamp.care.vo.result.ObsvCfgForRdDto;
import top.tangyh.lamp.care.vo.result.ObsvPtCfgDto;
import top.tangyh.lamp.care.vo.save.BObsvPtCfgSaveVO;
import top.tangyh.lamp.care.vo.save.ObsvPtCfgParam;
import top.tangyh.lamp.care.vo.update.BObsvPtCfgUpdateVO;
import top.tangyh.lamp.care.vo.result.BObsvPtCfgResultVO;
import top.tangyh.lamp.care.vo.query.BObsvPtCfgPageQuery;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * 病人观察项目配置表
 * </p>
 *
 * @author zqb
 * @date 2024-07-26 10:31:53
 * @create [2024-07-26 10:31:53] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/obsvCfgPt")
@Tag(name = "病人观察项目配置")
public class BObsvPtCfgController {
//    extends SuperController<BObsvPtCfgService, Long, BObsvPtCfg
//            , BObsvPtCfgSaveVO, BObsvPtCfgUpdateVO, BObsvPtCfgPageQuery, BObsvPtCfgResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private final BObsvPtCfgService bObsvPtCfgService;

    @Operation(summary = "查询观察项病人配置")
    @PostMapping("/pt/list")
    public R<List<ObsvPtCfgDto>> query(@Valid @RequestBody ObsvPtCfgQueryParam param) {
        return R.success(bObsvPtCfgService.getObsvPtCfg(param));
    }


    @Operation(summary = "查询观察项病人配置最后结果(用于观察记录)")
    @PostMapping("/pt/listForRd")
    public R<List<ObsvCfgForRdDto>> queryCfgByRd(@Valid @RequestBody ObsvPtCfgForRdParam param) {
        return R.success(bObsvPtCfgService.queryForRd(param));
    }

    @Operation(summary = "保存观察项病人配置")
    @PostMapping("/pt/save")
    public R<Integer> save(@Valid @RequestBody ObsvPtCfgParam param) {
        return R.success(bObsvPtCfgService.insertAndUpdate(param));
    }

}


